<template>
  <div class="app-loading">
    <div class="loading-text">系统资源加载中...</div>
  </div>
</template>

<script>

export default {
  name: 'AppLoading'
}
</script>

<style scoped lang="scss">
.app-loading {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  // 渐变色边框
  background: linear-gradient(45deg, transparent, transparent 40%, var(--color-primary));
  animation: spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  // 加载中文字
  .loading-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center;
    color: #fff;
    opacity: 0.8;
    font-size: 18px;
    // 抵消父元素的旋转
    animation: anti-spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  }
  &::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background-color: rgba(0, 0, 0, .45);
    border-radius: 50%;
    z-index: -1;
  }
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--color-primary), #2ecc71);
    opacity: 0.2;
    animation: pulse 2s ease-in-out infinite;
  }
}
// loading动画
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
// 脉冲动画
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.1); opacity: 0.3; }
  100% { transform: scale(1); opacity: 0.2; }
}
// 抵消旋转动画
@keyframes anti-spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(-360deg); }
}
</style>
